/*
 * LabView.fx
 *
 * Created on Mar 11, 2010, 9:44:25 PM
 */

package GraphsWindowPackage.LabPackage;


import javafx.scene.Node;

import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import GraphsWindowPackage.EntryView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.text.Text;


/**
 * @author quang
 */
 
public class LabView extends EntryView {
//    inherited attributes from EntryView:
//    public var name: String;
//    public var startShownTime: Number = 0;
//    public var endShownTime: Number = 0;
//    public var numPixPerTimeUnit: Number = 0;   //number of pixels per one time unit (day)

    var lab: Lab = bind (entry as Lab).createEntryInTimeRange(startShownTime, endShownTime);

    public override function create(): Node {

        def numLabChart = bind NumLabChart {
            startShownTime: startShownTime
            endShownTime: endShownTime
            lab: lab
            numPixPerTimeUnit: numPixPerTimeUnit
        }
        
        def ctgChart = bind CtgLabChart {
            numPixPerTimeUnit: numPixPerTimeUnit
            startShownTime: startShownTime
            ctgTimeSeq: lab.ctgTimeSeq
            ctgLabValSeq: lab.ctgLabValSeq
        }

        def nameField = HBox {
            layoutInfo: LayoutInfo {
                width: nameWidth - yLabelWidth
            }
            content: Text {
                content: "{entry.name} ({lab.unit})"
                wrappingWidth: nameWidth - yLabelWidth
            }
        }

        return HBox {
            content: bind if (shown) [ nameField, VBox {content: [numLabChart, ctgChart] } ]
                    else []
        } 
    }
}
